package cn.dianhun.om.jpa.controller;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author cyt
 * @create 2020-07-22 20:09
 */

@RestController
public class TestGui {

    @PostMapping("upload")
    public String upload(MultipartFile file) {
        String originalFilename = file.getOriginalFilename();
        return originalFilename;
    }

    @PostMapping("post")
    public Data api(@RequestBody Data msgBody) {
        System.out.println("-> " + msgBody.toString());
        return msgBody;
    }

    @RequestMapping("/get")
    public String get() {
        return "get";
    }

    @RequestMapping("/getParams")
    public String getParams(HttpServletRequest request, String name, @RequestParam("pwd") String pwd) {


        return "get" + name + pwd;
    }

    @RequestMapping("Put")
    public String Put() {
        return "Put";
    }

    @DeleteMapping("delete")
    public String delete() {
        return "delete";
    }

}

class Data {
    private String msgBody;

    public String getMsgBody() {
        return msgBody;
    }

    public void setMsgBody(String msgBody) {
        this.msgBody = msgBody;
    }

    @Override
    public String toString() {
        return "msgBody=" + msgBody;
    }
}
